#pragma  once

#include "LogDefine.h"
#include "LogUtil.h"
#include "ComDefinition.h"
class CLineDisplay
{
public:
    CLineDisplay();
    virtual ~CLineDisplay();
	virtual void InitPort(int nPort, int nParity = 2, int nBaud = 9600, ELineDisplayType eType = VC220) 
	{ 
		m_portInfo.nPort = nPort; 
		m_portInfo.nParity = nParity;
		m_portInfo.nBaud = nBaud;
		m_eType = eType;
	}

	virtual void Initialize() = 0;

	// Methods	V1.12
	virtual int Open();
	virtual int Close();

	// Need to add claim and release methods.
	virtual void ClearDescriptors() = 0;
	virtual void ClearText() = 0;
//	virtual void CreateWindow(int nVRow, int nVCol, int nVHeight, int nVWidth, int nWinHeight, int nWinWidth) = 0;
	virtual void DestroyWindow() = 0;
	virtual void DefineGlyph(int nGlyphCode, int nGlyph) = 0;
	virtual void DisplayBitmap(wstring strFileName, int nWidth, int nAlignmentX, int nAlignmentY) = 0;
	virtual void DisplayText(wstring strData, int nAttribute) = 0;
	virtual void DisplayTextAt(int nRow, int nCol, wstring strData, int nAttribute) = 0;
	virtual void ReadCharacterAtCursor(int &nData) = 0;
	virtual void RefreshWindow(/*int nWindow = 0*/) = 0;
	virtual void ScrollText(int nDirection, int nUnits) = 0;
	virtual void SetBitmap(int nBitmapNumber, wstring strFileName, int nWidth, int nAlignmentX, int nAlignmentY) = 0;
	virtual void SetDescriptor(int nDescriptor, int nAttribute) = 0;

	// Nonstandard
	virtual void ScrollTextEx(wstring strData, int nDirection, int nUnits) = 0;

	// Properties
public:
	_declspec(property(get = GetCursorColumn))	int CursorColumn;
	_declspec(property(get = GetCursorRow))  int CursorRow;

public:
	int GetCursorColumn() { return m_nCursorCol; }
	int GetCursorRow() { return m_nCursorRow; }

protected:
    struct PortInfo
	{
		int nPort;
		int nParity;
		int nBaud;
		HANDLE hCom;
		OVERLAPPED oWrite;
		OVERLAPPED oRead;
	};
	PortInfo m_portInfo;
	int m_nCursorCol;
	int m_nCursorRow;
	int m_nError;
	ELineDisplayType m_eType;
};



